package com.example.demo.common.exception;

import com.example.demo.common.vo.ResultVo;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * @author ccubee
 * @since 20-11-22 17:45
 */
@RestControllerAdvice
public class GlobalExceptionInterceptor {


    @ExceptionHandler(Exception.class)
    @ResponseBody
    public ResultVo exception(Exception e){
        return ResultVo.isFail();
    }

    @ExceptionHandler(DemoException.class)
    @ResponseBody
    public ResultVo exception(DemoException e){
        return ResultVo.isFail(e.getMessage());
    }

}
